home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / logbatch / waitr1.arc / WAITER.C next >
Text File  |  1988-11-01  |  1KB  |  57 lines

  1. /*------------------------------------------------------------------*
  2.  * waiter.c
  3.  *
  4.  *------------------------------------------------------------------*/
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8.  
  9. #define EXISTANCE  0
  10.  
  11. main(argc, argv)
  12. int argc;
  13. char **argv;
  14. {
  15.  
  16.      /* set variables */
  17.      char filname[80];
  18.      char dos_command[80];
  19.      char repeat_cmd[1];
  20.  
  21.      /* verify enough arguements were entered on the command line */
  22.      if(argc < 3)
  23.      {
  24.         printf("Usage: WAITER <file-to-detect> <DOS command> [R]\n\n");
  25.         exit(1);
  26.      }
  27.  
  28.      strcpy(repeat_cmd,argv[3]);   /* use third arg as possible repeat */
  29.  
  30.      /* move command line variables to strings */
  31.      strcpy(filname,argv[1]);
  32.      strcpy(dos_command,argv[2]);
  33.  
  34.      /* check keyboard buffer and exit if user indicates */
  35.      if(kbhit())
  36.         exit(0);
  37.  
  38.      /* display message on screen */
  39.      printf("Waiting for:   To perform:\n");
  40.      printf("------------   ----------------------\n");
  41.      printf("%-12s   %s\n", filname, dos_command);
  42.  
  43.      /* watch for filename until a key is pressed */
  44.      while(!(kbhit()))
  45.      {
  46.         /* if the file exists, do the dos command */
  47.         if(!(access(filname, EXISTANCE)))
  48.         {
  49.            system(dos_command);
  50.            if( strcmpi(repeat_cmd, "R") != 0)
  51.               exit(0);
  52.         }
  53.      }
  54.      exit(0);
  55. }
  56.  
  57.